package com.base.system.managedBean;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import javax.faces.context.FacesContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.operamasks.faces.annotation.BeforeRender;
import org.operamasks.faces.annotation.Bind;
import org.operamasks.faces.annotation.DataModel;
import org.operamasks.faces.annotation.Inject;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import org.operamasks.faces.component.grid.impl.UIDataGrid;

import com.base.commons.SpringBeanHolder;
import com.base.organization.entity.DepartmentalUnit;
import com.base.organization.service.IOrganizationService;

/**
 * 
 * This managed bean is generated automatically
 */
@ManagedBean(name = "system_lowerDepartmentListOfOneCentralUnitBean", scope = ManagedBeanScope.SESSION)
public class LowerDepartmentListOfOneCentralUnitBean implements Serializable {
	private final static Log logger = LogFactory
			.getLog(LowerDepartmentListOfOneCentralUnitBean.class);
	protected IOrganizationService organizationService = SpringBeanHolder
			.getBean("orgService");
	@Inject
	private FacesContext context;

	@Bind(id = "centralUnitGrid", attribute = "binding")
	private UIDataGrid centralUnitGrid;
	@DataModel(id = "centralUnitGrid")
	private List<DepartmentalUnit> data = new LinkedList<DepartmentalUnit>();

	@BeforeRender
	public void beforeRender(boolean isPostback) {
		logger.debug("Listbean 中的 postBack:" + isPostback);
		String unitId = context.getExternalContext().getRequestParameterMap()
				.get("unitId");
		data = organizationService.getChildDepartmentByCentralUnit(Integer
				.valueOf(unitId));
	}
}
